package com.wgts.wgts.control.recycleview;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public abstract  class BaseLoadRefreshAdapter extends RecyclerView.Adapter{


    private final int TYPE_BODY = 1;

    private final int TYPE_FOOT = 2;

    private final int TYPE_HEAD = 3;

    // 正在加载
    private final int LOADING = 1;
    // 加载完成
    private final int LOADING_COMPLETE = 2;
    // 加载到底
    private final int LOADING_END = 3;



    @Override
    public int getItemViewType(int position) {
        // 最后一个item设置为FooterView
        if (position + 1 == getItemCount()) {
            return TYPE_FOOT;
        } else {
            return TYPE_BODY;
        }
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //进行判断显示类型，来创建返回不同的View
        if (viewType == TYPE_BODY) {
            return bodyViewHolder();
        } else if (viewType == TYPE_FOOT && needfoot()) {
            return footViewHolder();
        } else if(viewType == TYPE_HEAD && needHead()){
            return headViewHolder();
        }
        return null;
    }




    public abstract RecyclerView.ViewHolder bodyViewHolder();

    public abstract RecyclerView.ViewHolder footViewHolder();

    public abstract RecyclerView.ViewHolder headViewHolder();

    public abstract boolean needfoot();

    public abstract boolean needHead();

}
